package com.thesis.manage.controller;

import com.thesis.manage.common.controller.AbstractController;
import com.thesis.manage.domain.Thesis;
import com.thesis.manage.service.ThesisService;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author php
 * @date 2018/2/3
 */
@RestController
@RequestMapping("/thesis")
public class ThesisController extends AbstractController {
    @Resource
    private ThesisService thesisService;

    @GetMapping("/list")
    public Map<String, Object> list(final Thesis thesis, final Pageable pageable) {
        return buildMessage(() -> thesisService.findByPage(thesis, pageable, null));
    }

    /**
     * 通过主键删除
     *
     * @param id id
     * @return map
     */
    @DeleteMapping("/{id}")
    public Map<String, Object> delete(final @PathVariable Long id) {
        return buildMessage(() -> {
            thesisService.deleteById(id);
            return null;
        });
    }

}
